﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="CopyVersion.aspx.vb" Inherits="CopyVersion" %>

<%@ Register Assembly="ISNet.WebUI.WebGrid" Namespace="ISNet.WebUI.WebGrid" TagPrefix="ISWebGrid" %>
<%@ Register Assembly="ISNet.WebUI.WebDesktop" Namespace="ISNet.WebUI.WebDesktop" TagPrefix="ISWebDesktop" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <script src="script/tinybox.js"></script>
    <link href="script/style.css" rel="stylesheet" />
    <script>
        function popupwaitForce() {
            TINY.box.show({ iframe: 'loading.html', boxid: 'frameless', close: 0, width: 300, height: 260, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { } });
            CustomRequestCopyForce();
            return false;
        }
        function popupwait() {
            TINY.box.show({ iframe: 'loading.html', boxid: 'frameless', close: 0, width: 300, height: 260, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { } });
            return false;
        }
        function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) {
            menuObject.Items[0].Hide();

            return true;
        }

        function release(Func) {
            if (confirm('กรุณายืนยันการ Release กลับ') == false) {
                return false;
            }
            //alert(id); return;
            var version = document.getElementById("<%= HdMyVersion.ClientID %>").value;
            //alert(version);
            // return false;
            var grid = ISGetObject("WebGrid1");
            grid.AddInput("type", "3");
            var data = Func + "," + version;
            grid.AddInput("data", data);

            grid.SendCustomRequest();



            event.cancelBubble = true;
            event.returnValue = false;
        }

        function release2(Func) {
            if (confirm('กรุณายืนยันการ ยกเลิกส่งแผน') == false) {
                return false
            }
            //alert(id); return;
            var version = document.getElementById("<%= HdMyVersion.ClientID %>").value;
            //alert(version);
            // return false;
            var grid = ISGetObject("WebGrid1");

            var data = Func + "," + version;
            grid.AddInput("data", data);
            grid.AddInput("type", "3");
            grid.SendCustomRequest();



            event.cancelBubble = true;
            event.returnValue = false;
        }
        function CustomRequestCopy() {
            var version = document.getElementById("<%= HdMyVersion.ClientID %>").value;
                var txtconf = "กรุณายืนยันการ Copy Version ไปยัง Version " + version;
                if (confirm(txtconf) == false) {
                    TINY.box.hide();
                    return false;
                }

                var grid = ISGetObject("WebGrid1");
                grid.AddInput("type", "1");
                grid.SendCustomRequest();

                return false;
                event.cancelBubble = true;
                event.returnValue = false;

            }

            function CustomRequestCopyForce() {
                //if (confirm('Force Copy Version') == false) {
                //    return false;
                //}

                var grid = ISGetObject("WebGrid1");
                grid.AddInput("type", "2");
                grid.SendCustomRequest();


                event.cancelBubble = true;
                event.returnValue = false;

                return false;
            }

            function setCause() {

                TINY.box.show({ url: 'CauseCopy.aspx', closejs: function () { checkCause2() } })

                //TINY.box.show({ iframe: 'CauseCopy.aspx', boxid: 'frameless', width: 500, height: 200, fixed: false, maskid: 'lightmask', maskopacity: 40, closejs: function () { checkCause() } });

                return false;

            }

            function checkCause2() {
                //alert("checkCause2");
                // TINY.box.hide();
                var txtCause = document.getElementById('<%=HdCause.ClientID%>').value
                if (txtCause.replace(" ", "") == "") {

                } else {
                    //alert(txtCause);
                    // CustomRequestCopyForce();
                    document.getElementById('<%=HdCause.ClientID%>').value = "";
                }
                // return false;
            }
            function checkCause() {
                // alert("dd");
                var txtCause = document.getElementById('txtAreaCause').value;
                // alert(txtCause);
                if (txtCause.replace(" ", "") == "") {
                    alert("กรุณาระบุเหตุผล");
                    return false;
                } else {
                    document.getElementById('<%=HdCause.ClientID%>').value = txtCause;
                    //TINY.box.hide();
                    window.close();
                    var ForceCopy = document.getElementById('<%=Button2.ClientID%>');
                    ForceCopy.click();
                }
                return false;

            }

            function formrefresh() {
                window.location = 'CopyVersion.aspx';
            }

            function releaseclik() {
                var txtconf = "กรุณายืนยันการ Release Version กลับไปยังเวอร์ชันก่อนหน้า \n โปรดระวังข้อมูลที่ถูกบันทึกในเวอร์ชันนี้จะถูกลบทั้งหมด !!";
                if (confirm(txtconf) == false) {
                    return false;
                }
                else {
                    return true;
                }
            }
            function WebGrid1_OnUnhandledError(controlId, action, lastRequestObject, errorString) {
                return false;
            }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <br />
    <br />
    <asp:HiddenField ID="HdMyVersion" runat="server" />
    <asp:HiddenField ID="HdUser" runat="server" />
    <asp:HiddenField ID="HdCause" runat="server"></asp:HiddenField>
    <center>
  <div style=" width: 1000px; border: solid; border-color: gray; border-width: 1px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; text-align: right; padding: 5px 5px 5px 5px;">
            <div style="text-align: right; margin-top: 5px;">
                <div align="left" style="width: 400px; float: left">
                    <asp:Label ID="Label1" runat="server" Text="ระบบจัดทำงบประมาณ >> จัดทำงบประมาณ >> Copy Version"></asp:Label>
                </div>
                ปี&nbsp;
            <asp:TextBox ID="PlanYearsTxt" runat="server" Width="50px" Enabled="false" Style="text-align: center;"></asp:TextBox>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="#" title="ค้นหา">
                <asp:ImageButton ID="SearhBtn" runat="server" ImageUrl="Images/planIc/search.png" Visible="false" /></a>
                &nbsp;&nbsp;<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Images/planIc/backRelease2.png" OnClientClick="return releaseclik()"></asp:ImageButton>&nbsp;&nbsp;<a href="#" title="Coppy Version"><asp:ImageButton ID="coppy_btn" runat="server" OnClientClick=" popupwait(); return CustomRequestCopy();" ImageUrl="Images/planIc/copy.png"  /></a>
                &nbsp;&nbsp;<a id="ForceCopyBtn" runat="server" href="#" title="Force Copy Version X" ><img src="Images/planIc/forceCopy.png" alt="Force Copy Version X" height="21"  onclick="setCause();"/></a><%--<asp:ImageButton ToolTip="Force Copy Version X" ID="ForceCopyBtn" runat="server" OnClientClick="return setCause(); " ImageUrl="Images/planIc/forceCopy.png" Style="height: 21px" />--%>
                 <div style="visibility:hidden; height:0px;"><asp:Button Style="height: 0px" ID="Button2" runat="server" OnClientClick="return popupwaitForce();" Text="Button"></asp:Button></div>
            </div>
        </div>
</center>
    <br />
    <table style="width: 100%;">
        <tr>
            <td align="center">
                <div id="div1" runat="server" style="text-align: left; width: 1000px; border: solid; border-color: gray; border-width: 1px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow: 5px 5px 5px #808080; height: 410px;">

                    <div style="padding-bottom: 5px;"><strong>&nbsp;</strong></div>


                    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="350px" Width="100%" EnableTheming="True">
                        <asp:TabPanel ID="TabPanel1" runat="server" HeaderText="FundCenter">
                            <ContentTemplate>
                                <ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Width="100%" DefaultStyleMode="Silver" Height="350px">
                                    <LayoutSettings AllowDelete="Yes" AllowSorting="Yes" ColumnFooters="Yes" NewRowLostFocusAction="AlwaysUpdate"
                                        ResetNewRowValuesOnError="False" InProgressUIBehavior="ChangeCursorToHourGlass"
                                        AlwaysShowHelpButton="False" PagingMode="ClassicPaging" PagingSize="10" ColumnFooterAggregateMode="CalculateAllData"
                                        VirtualLoadMode="LargeData" AllowGrouping="Yes" VirtualPageSize="10">
                                        <RowStyle Font-Names="Tahoma" Font-Size="9pt" CustomRules="overflow: hidden;" />
                                        <AlternatingRowStyle Font-Names="Tahoma" Font-Size="9pt" BackColor="#FBFBFB" CustomRules="overflow: hidden;" />
                                        <ClientSideEvents OnRowValidate="WebGrid1_OnRowValidate" OnRowContextMenu="WebGrid1_OnRowContextMenu" OnUnhandledError="WebGrid1_OnUnhandledError" />
                                    </LayoutSettings>
                                    <RootTable DataKeyField="FundCenterCode" NewRowInfoText="เพิ่มรายการ">
                                        <Columns>
                                            <ISWebGrid:WebGridColumn Caption="FundCenter" ColumnType="Template" Name="FundCenter" Width="350px">
                                                <CellTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='' Font-Bold="True" Font-Size="Medium"></asp:Label>
                                                    <asp:Image ID="Image1" runat="server" Width="16px" Height="16px" />
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("FundCenterName")%>'></asp:Label>

                                                </CellTemplate>
                                            </ISWebGrid:WebGridColumn>
                                            <ISWebGrid:WebGridColumn Name="version" Width="150px" DataMember="Now_version" Caption="version">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center" />
                                            </ISWebGrid:WebGridColumn>
                                            <ISWebGrid:WebGridColumn Name="CreateDate" DataMember="CreateDate" Width="300px" Caption="วันที่ล่าสุด">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center" />
                                            </ISWebGrid:WebGridColumn>
                                            <ISWebGrid:WebGridColumn Caption=" " ColumnType="Template" Name="Release" Width="118px">
                                                <CellTemplate>
                                                    <a href="#" id="<%# Eval("FundCenterCode")%>" onclick="release2(id);">
                                                        <asp:Image ID="Image3" ImageUrl="Images/planIc/cancel_release.png" runat="server" />
                                                    </a>
                                                </CellTemplate>
                                            </ISWebGrid:WebGridColumn>

                                        </Columns>
                                    </RootTable>

                                </ISWebGrid:WebGrid>

                            </ContentTemplate>
                        </asp:TabPanel>

                    </asp:TabContainer>
                </div>

            </td>
        </tr>
    </table>




    <%=AlertText %>
    <%=ScriptText %>
</asp:Content>

